﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;

namespace LZSchedule
{
    class Schedule
    {
        public static string ExecuteProcess(string ProcessFileName, string ProcessArguments)
        {
            string Result = "";
            Process oProcess = null;
            try
            {
                ProcessStartInfo oInfo = new ProcessStartInfo(ProcessFileName, ProcessArguments);
                oInfo.CreateNoWindow = true;
                oInfo.UseShellExecute = false;
                oInfo.RedirectStandardError = true;
                oInfo.RedirectStandardOutput = true;
                oInfo.RedirectStandardInput = true;
                oProcess = Process.Start(oInfo);

                oProcess.WaitForExit(10 * 1000);
                if (!oProcess.HasExited)
                {
                    oProcess.Kill();
                }
                Result = oProcess.StandardError.ReadToEnd();
            }
            catch (Exception ex)
            {

                Result = ex.ToString();
            }
            finally
            {
                oProcess.Close();
            }
            return Result;
        }
    }

    class Program
    {

        static void Main(string[] args)
        {
            string s = Schedule.ExecuteProcess("notepad.exe", @"");

        }
    }
}
